package com.atguigu.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo1 {
    public static void main(String[] args) {
        //一池多线程
        ExecutorService executorService = Executors.newFixedThreadPool(5);

        try {
            for (int i = 1;i<=10;i++){
                executorService.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"执行中----");
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            executorService.shutdown();
        }

    }
}
